import Mock from 'mockjs'
import { getUserInfo } from './login'
import {
  getTableData,
  getDragList,
  uploadImage,
  getOrgData,
  getTreeSelectData
} from './data'
import {
  getMessageInit,
  getContentByMsgId,
  hasRead,
  removeReaded,
  restoreTrash,
  messageCount
} from './user'
import {
  getAgentTableData,
  setFormData,
  getUserList,
  getAgentChargeStationData,
  getAgentSelectStationTimeCostData,
  getAgentPileData,
  getCustomInfoData,
  getAppUserManageInfo,
  getAppSuggestFeedbackInfo,
  getLoginUserInfo,
  getUserRoleList,
  getUserLoginLogInfo,
  getSystemMsgInfo
} from './data2'

// 配置Ajax请求延时，可用来测试网络延迟大时项目中一些效果
Mock.setup({
  timeout: 1000
})

// 拓展mockjs
// 手机号
Mock.Random.extend({
  phone: function () {
    var phonePrefixs = ['132', '135', '189', '199', '177', '155'] // 自己写前缀哈
    return this.pick(phonePrefixs) + Mock.mock(/\d{8}/) // Number()
  }
})
// 车牌
Mock.Random.extend({
  licensePlate: function () {
    var province = ['鄂', '粤', '苏', '赣']
    var area = ['A', 'B', 'C', 'D']
    var number = [
      'N',
      'G',
      'Q',
      'T',
      'K',
      'M',
      'R',
      1,
      2,
      3,
      4,
      5,
      6,
      7,
      8,
      9,
      0
    ]
    return (
      this.pick(province) + this.pick(area) + this.string(number.join(''), 5)
    )
  }
})

// 登录相关和获取用户信息
// Mock.mock(/\/login/, login)
// Mock.mock(/\/logout/, logout)
Mock.mock(/\/get_info/, getUserInfo)
Mock.mock(/\/get_table_data/, getTableData)
Mock.mock(/\/get_drag_list/, getDragList)
Mock.mock(/\/save_error_logger/, 'success')
Mock.mock(/\/image\/upload/, uploadImage)
Mock.mock(/\/message\/init/, getMessageInit)
Mock.mock(/\/message\/content/, getContentByMsgId)
Mock.mock(/\/message\/has_read/, hasRead)
Mock.mock(/\/message\/remove_readed/, removeReaded)
Mock.mock(/\/message\/restore/, restoreTrash)
Mock.mock(/\/message\/count/, messageCount)
Mock.mock(/\/get_org_data/, getOrgData)
Mock.mock(/\/get_tree_select_data/, getTreeSelectData)

Mock.mock(/\/get_agent_table_data/, getAgentTableData)
Mock.mock(/\/get_agent_user_data/, getUserList)
Mock.mock(/\/get_agent_charge_station_data/, getAgentChargeStationData)
Mock.mock(
  /\/get_agent_select_station_time_cost_data/,
  getAgentSelectStationTimeCostData
)
Mock.mock(/\/get_agent_pile_data/, getAgentPileData)
Mock.mock(/\/set_form_data/, setFormData)
Mock.mock(/\/get_custom_info_data/, getCustomInfoData)
Mock.mock(/\/get_appuser_manage_info/, getAppUserManageInfo)
Mock.mock(/\/get_app_suggest_feedback_info/, getAppSuggestFeedbackInfo)
Mock.mock(/\/get_login_user_info/, getLoginUserInfo)
Mock.mock(/\/get_user_role_manage_info/, getUserRoleList)
Mock.mock(/\/get_user_login_log_info/, getUserLoginLogInfo)
Mock.mock(/\/get_system_msg_info/, getSystemMsgInfo)

export default Mock
